﻿@model IPageable<XPressify.Models.NotificationListModel>
@using Omu.Awesome.Core;
@using Omu.Awesome.Mvc.Helpers;

@{
    ViewBag.Title = "Notifications";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2 style="color:#222;">Notifications</h2>


<script type="text/javascript">


    function successDeleteNotification(id) {
        $("#" + id).hide("fast", function () {
            $("#" + id).remove();
        }
        );
    }
</script>


<br />

<table>


@{var index = 0;
  var notificationId = "";
    foreach (var item in Model.Page)
    {
        <tr id="@item.Notification.Id">
            <td width="10px">
                @Html.Confirm("Are you sure you want to delete this notification?", "myconfirmBtn", title: "Delete notification", yesText: "Delete")      
                @*@using (Html.BeginForm("DeleteNotification", "Home", FormMethod.Post, new { style = "width:20px" }))*@
                @using (Ajax.BeginForm("DeleteNotification", "Home", new AjaxOptions { UpdateTargetId = "DummyDiv", OnSuccess = "successDeleteNotification(\'" + item.Notification.Id + "\')" , InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, HttpMethod = "POST" }))
                {
                        <input type="hidden" name="id" value="@item.Notification.Id" />
                        <input type="submit" value="x" class="myconfirmBtn" id="nounderline" onmouseover="changeIdToObject(this)" onmouseout="changeIdToObject(this)"/>
                }
            </td>
            <td style="word-break:break-all">
                @Html.Raw(item.Notification.Content)
            </td>
            
        </tr>
    index++;
    }
}
</table>
@Html.Pagination()

<div style="display:none" id="DummyDiv"></div>
